<?php
require("../class/connect.php");
include("../class/db_sql.php");
include("../class/config.php");
include("../class/class.php");
include("../class/functions.php");
include LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
is_login($logininid,$loginin,$loginrnd);
$classid=(int)$_GET['classid'];
$bclassid=(int)$_GET['bclassid'];
$id=$_GET['id'];
if(empty($id))
{
	$id=$_POST['id'];
}
$id=(int)$id;
$checked=(int)$_GET['checked'];
//验证权限
CheckLevel($logininid,$loginin,$classid,"pl");
$keyboard=$_GET['keyboard'];
$keyboard=RepPostVar2($keyboard);
$show=$_GET['show'];
$start=(int)$_GET['start'];
$page=(int)$_GET['page'];
$line=15;//每行显示
$page_line=15;
$offset=$start+$page*$line;
$search="&bclassid=$bclassid&classid=$classid&id=$id&checked=$checked&keyboard=$keyboard&show=$show";
$a="";
if($checked)
{
	$a.=" where checked=1";
}
//单个
if($id)
{
	if(empty($a))
	{
		$and=' where ';
	}
	else
	{
		$and=' and ';
	}
	$a.=$and."id='$id'";
}
//单个
if($classid)
{
	if(empty($a))
	{
		$and=' where ';
	}
	else
	{
		$and=' and ';
	}
	$a.=$and."classid='$classid'";
}
if($keyboard)
{
	if(empty($a))
	{
		$and=' where ';
	}
	else
	{
		$and=' and ';
	}
	if($show==1)//作者
	{
		$a.=$and."(username like '%".$keyboard."%')";
	}
	elseif($show==2)//评论内容
	{
		$a.=$and."(saytext like '%".$keyboard."%')";
	}
	elseif($show==3)//ip
	{
		$a.=$and."(sayip like '%".$keyboard."%')";
	}
	else
	{
		$a.=$and."(sayip like '%".$keyboard."%' or username like '%".$keyboard."%' or saytext like '%".$keyboard."%')";
	}
}
$totalquery="select count(*) as total from {$dbtbpre}enewspl".$a;
$num=$empire->gettotal($totalquery);//取得总条数
$query="select plid,username,saytime,saytext,sayip,id,classid,checked,zcnum,fdnum,userid,isgood from {$dbtbpre}enewspl".$a;
$query.=" order by plid desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page1($num,$line,$page_line,$start,$page,$search);
//位置
$url="<a href=ListAllPl.php>管理评论</a>";
//操作的栏目
$fcjsfile='../data/fc/cmsclass.js';
$do_class=GetFcfiletext($fcjsfile);
if($classid)
{
	$do_class=str_replace("<option value='$classid'","<option value='$classid' selected",$do_class);
}
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理评论</title>
<link href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<script>
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }
</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td width="50%">位置： 
      <?=$url?>
    </td>
    <td><div align="right">
        <input type="button" name="Submit5" value="管理评论过滤字符" onclick="self.location.href='PlWord.php';">&nbsp;&nbsp;&nbsp;
        <input type="button" name="Submit5" value="管理评论表情" onclick="self.location.href='other/plface.php';">
      </div></td>
  </tr>
</table>

  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <form name="form2" method="get" action="ListAllPl.php">
    <tr> 
      <td>信息ID： 
        <input name="id" type="text" id="id" value="<?=$id?>" size="6">
        关键字： 
        <input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>"> 
        <select name="show" id="show">
          <option value="0">不限</option>
          <option value="1">作者</option>
          <option value="2">评论内容</option>
          <option value="3">ip</option>
        </select>
		<select name="classid">
			<option value="0">所有栏目</option>
			<?=$do_class?>
		</select>
		<input name="checked" type="checkbox" id="checked" value="1">
        未审核 <input type="submit" name="Submit2" value="搜索评论">
      </td>
    </tr>
    <tr>
      <td> </td>
    </tr>
	</form>
  </table>
<form name="form1" method="post" action="enews.php" onsubmit="return confirm('确认要操作?');">
<input type=hidden name=bclassid value=<?=$bclassid?>>
<input type=hidden name=classid value=<?=$classid?>>
<input type=hidden name=id value=<?=$id?>>
  <input name="isgood" type="hidden" id="isgood" value="1">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder" style="WORD-BREAK: break-all; WORD-WRAP: break-word">
    <tr class="header"> 
      <td width="21%" height="25"><div align="center">网名</div></td>
      <td width="49%" height="25"><div align="center">评论内容(双击内容，进入信息评论页)</div></td>
      <td width="24%" height="25"><div align="center">所属信息</div></td>
      <td width="6%" height="25"><div align="center">删除</div></td>
    </tr>
    <?
	while($r=$empire->fetch($sql))
	{
		if(!empty($r[checked]))
		{$checked=" title='未审核' style='background:#99C4E3'";}
		else
		{$checked="";}
		if($r['userid'])
		{
			$r['username']="<a href='member/AddMember.php?enews=EditMember&userid=$r[userid]' target='_blank'><b>$r[username]</b></a>";
		}
		if(empty($r['username']))
		{
			$r['username']='匿名';
		}
		if($r[isgood])
		{
			$r[saytime]='<font color=red>'.$r[saytime].'</font>';
		}
		//替换表情
		$r['saytext']=RepPltextFace($r['saytext']);
		//信息
		$title='';
		if($class_r[$r[classid]][tbname])
		{
			$infor=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$r[classid]][tbname]." where id='$r[id]' limit 1");
			$titleurl=sys_ReturnBqTitleLink($infor);
			$title="<a href='$titleurl' target='_blank'>$infor[title]</a>";
		}
	?>
    <tr bgcolor="#FFFFFF" id=pl<?=$r[plid]?>> 
      <td height="25" valign="top"><div align="center"> 
          <table width="100%" border="0" cellspacing="1" cellpadding="3">
            <tr> 
              <td width="20%">网名</td>
              <td width="80%"> 
                <?=$r[username]?>
              </td>
            </tr>
            <tr> 
              <td>IP</td>
              <td> 
                <?=$r[sayip]?>
              </td>
            </tr>
            <tr> 
              <td>时间</td>
              <td> 
                <?=$r[saytime]?>
              </td>
            </tr>
          </table>
        </div></td>
      <td height="25" valign="top" ondblclick="window.open('../pl?classid=<?=$r[classid]?>&id=<?=$r[id]?>');"> 
        <?=$r[saytext]?>
      </td>
      <td height="25">
<div align="center"><?=$title?></div></td>
      <td height="25">
<div align="center"> 
          <input name="plid[]" type="checkbox" id="plid" value="<?=$r[plid]?>" onclick="if(this.checked){pl<?=$r[plid]?>.style.backgroundColor='#DBEAF5';}else{pl<?=$r[plid]?>.style.backgroundColor='#ffffff';}"<?=$checked?>>
        </div></td>
    </tr>
    <?
	}
	db_close();
	$empire=null;
	?>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="4">&nbsp;&nbsp; 
        <?=$returnpage?>
        &nbsp;&nbsp; <input type="submit" name="Submit" value="审核评论" onClick="document.form1.enews.value='CheckPl_all';"> 
        &nbsp;&nbsp;&nbsp; <input type="submit" name="Submit3" value="推荐评论" onClick="document.form1.enews.value='DoGoodPl_all';document.form1.isgood.value='1';"> 
        &nbsp;&nbsp;&nbsp; <input type="submit" name="Submit4" value="取消推荐评论" onClick="document.form1.enews.value='DoGoodPl_all';document.form1.isgood.value='0';"> 
        &nbsp;&nbsp;&nbsp; <input type="submit" name="Submit" value="删除" onClick="document.form1.enews.value='DelPl_all';"> 
        <input name="enews" type="hidden" id="enews" value="DelPl_all"> &nbsp; 
        <input type=checkbox name=chkall value=on onclick=CheckAll(this.form)>
        选中全部</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="4"><font color="#FF0000">备注：多选框为蓝色代表未审核评论，加粗网名为登陆会员，发布时间红色为推荐评论</font></td>
    </tr>
  </table>
</form>
</body>
</html>